local skel = fk.CreateSkill {
  name = "sj_zhoushuhuizhan__shiying",
}

Fk:loadTranslationTable{
  ["sj_zhoushuhuizhan__shiying"] = "十影",
  [":sj_zhoushuhuizhan__shiying"] = "每回合限一次，当你需要使用或打出基本牌时，你可以与当前回合角色互相弃置对方一张手牌，若弃置了【影】，你视为使用你需要使用的牌；若弃置了你需要使用的牌，你获得三张【影】。",

  ["#sj_zhoushuhuizhan__shiying"] = "十影：你可以与 %dest 互相弃置对方一张手牌，若弃置了【影】，你视为使用你需要使用的牌；若弃置了你需要使用的牌，你获得三张【影】",
  ["#sj_zhoushuhuizhan__shiying_dis"] = "十影：弃置 %dest 一张手牌",

  ["$sj_zhoushuhuizhan__shiying1"] = "",
  ["$sj_zhoushuhuizhan__shiying2"] = "",
}

local U = require "packages.utility.utility"

skel:addEffect("viewas", {
  pattern = ".|.|.|.|.|basic",
  prompt = function (self, player, selected_cards, selected)
      return "#sj_zhoushuhuizhan__shiying::"..Fk:currentRoom().current.id
  end,
  interaction = function(self, player)
    local all_names = Fk:getAllCardNames("b")
    local names = player:getViewAsCardNames(skel.name, all_names)
    if #names == 0 then return end
    return UI.CardNameBox {choices = names, all_names = all_names}
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = skel.name
    return card
  end,
  before_use = function (self, player, use)
    local room = player.room
    local players = {player,room.current}
    local shade = false
    for i = 1, 2, 1 do
      if not players[2]:isKongcheng() and not players[1].dead then
        local card = Fk:getCardById(room:askToChooseCard(players[1],{
          target = players[2],
          flag = "h",
          skill_name = skel.name,
          prompt = "#sj_zhoushuhuizhan__shiying_dis::"..players[2].id,
        }))
        room:throwCard(card,skel.name,players[2],players[1])
        if use.card.name == card.name then
            room:moveCards({
            ids = U.getShade(room, 3),
            to = player,
            toArea = Card.PlayerHand,
            moveReason = fk.ReasonJustMove,
            proposer = player,
            skillName = skel.name,
            moveVisible = true,
          })
        end
        if not shade and card.name == "shade" then
          shade = true
        end
      end
      players = table.reverse(players)
    end
    if not shade then
      return skel.name
    end
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(skel.name) == 0 and not (player:isKongcheng() or Fk:currentRoom().current:isKongcheng())
  end,
  enabled_at_response = function(self, player, response)
    return player:usedSkillTimes(skel.name) == 0 and not (player:isKongcheng() or Fk:currentRoom().current:isKongcheng())
  end,
})

return skel
